package cumeo89.chii.client.entry.renderer;

import static cumeo89.chii.client.entry.Constants.*;
import cumeo89.chii.client.entry.AbstractRenderer;
import cumeo89.chii.client.entry.Renderer;
import cumeo89.chii.client.ui.TrivialNamedPanel;
import cumeo89.chii.client.util.XMLUtil;

public class DefinitionRenderer extends AbstractRenderer {

	private TrivialNamedPanel container;

	public DefinitionRenderer() {
		container = new TrivialNamedPanel("li", new String[] { A_DEF_CONTENT });
		container.setStyleName("definition");
		initWidget(container);
	}

	@Override
	public void addRenderer(Renderer r) {
		if (XMLUtil.hasTag(r.getRenderedNode(), E_CONTEXT_LIST)) {
			container.insert(r.getWidget(), 0);
		} else {
			super.addRenderer(r);
		}
	}

	@Override
	public void insertRenderer(Renderer r, Renderer b) {
		if (XMLUtil.hasTag(r.getRenderedNode(), E_CONTEXT_LIST)) {
			container.insert(r.getWidget(), 0);
		} else {
			super.insertRenderer(r, b);
		}
	}

}
